//
//  ShuangSeQiu.m
//  TheRicher
//
//  Created by 李晓东 on 2018/1/18.
//  Copyright © 2018年 PeanutXu. All rights reserved.
//

#import "ShuangSeQiu.h"
#import "ShuangSeQiu+TypeNumber.h"

@implementation ShuangSeQiu

- (instancetype)initShuangSeQiu:(NSDictionary *)dict{
    if (self = [super init]) {
        [self setValuesForKeysWithDictionary:dict];
        
    }
    return self;
}

+ (instancetype)shuangSeQiuWithDict:(NSDictionary *)dict{
    return [[self alloc]initShuangSeQiu:dict];
}

+ (instancetype)shuangSeQiuWithDictFromServer:(NSDictionary *)dict {
    NSString *numberStr = dict[@"number"];
    NSArray *numberArray = [numberStr componentsSeparatedByString:@" "];
    ShuangSeQiu *shuangSeQiu = [[ShuangSeQiu alloc]init];
    [shuangSeQiu setRed1:numberArray[0]];
    [shuangSeQiu setRed2:numberArray[1]];
    [shuangSeQiu setRed3:numberArray[2]];
    [shuangSeQiu setRed4:numberArray[3]];
    [shuangSeQiu setRed5:numberArray[4]];
    [shuangSeQiu setRed6:numberArray[5]];
    
    [shuangSeQiu setBlue:dict[@"refernumber"]];
    [shuangSeQiu setIssueno:dict[@"issueno"]];
    [shuangSeQiu setCaipiaoId:[dict[@"caipiaoid"] integerValue]];
    [shuangSeQiu setOpendate:dict[@"opendate"]];
    [[ShuangSeQiu alloc]insertType:dict inObj:shuangSeQiu];
    return shuangSeQiu;
}

- (NSString *)number{
    NSString *numberStr = [NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@", _red1, _red2, _red3, _red4, _red5, _red6];
    return numberStr;
}

- (NSString *)numberAndRefernumber{
    NSString *numberStr = [NSString stringWithFormat:@"%@ %@ %@ %@ %@ %@ %@", _red1, _red2, _red3, _red4, _red5, _red6, _blue];
    return numberStr;
}

- (BOOL)judgeWhetherItContain:(NSString *)ball {
    if ([self.red1 isEqualToString:ball]) {
        return YES;
    } else if ([self.red2 isEqualToString:ball]){
        return YES;
    } else if ([self.red3 isEqualToString:ball]){
        return YES;
    }else if ([self.red4 isEqualToString:ball]){
         return YES;
    } else if ([self.red5 isEqualToString:ball]){
        return YES;
    } else if ([self.red6 isEqualToString:ball]){
         return YES;
    } else {
        return NO;
    }
    
}

- (void)insertType:(NSDictionary *)dict inObj:(ShuangSeQiu *)shuangSeQiu{
    [shuangSeQiu setType1:dict[@"type"]];
    [shuangSeQiu setType2:dict[@"type"]];
    [shuangSeQiu setType3:dict[@"type"]];
    [shuangSeQiu setType4:dict[@"type"]];
    [shuangSeQiu setType5:dict[@"type"]];
    [shuangSeQiu setType6:dict[@"type"]];
    [shuangSeQiu setType7:dict[@"type"]];
    [shuangSeQiu setType8:dict[@"type"]];
    [shuangSeQiu setType9:dict[@"type"]];
    [shuangSeQiu setType10:dict[@"type"]];
    [shuangSeQiu setType11:dict[@"type"]];
    [shuangSeQiu setType12:dict[@"type"]];
    [shuangSeQiu setType13:dict[@"type"]];
    [shuangSeQiu setType14:dict[@"type"]];
    [shuangSeQiu setType15:dict[@"type"]];
    [shuangSeQiu setType16:dict[@"type"]];
    [shuangSeQiu setType17:dict[@"type"]];
    [shuangSeQiu setType18:dict[@"type"]];
    [shuangSeQiu setType19:dict[@"type"]];
    [shuangSeQiu setType20:dict[@"type"]];
    [shuangSeQiu setType21:dict[@"type"]];
    [shuangSeQiu setType22:dict[@"type"]];
    [shuangSeQiu setType23:dict[@"type"]];
    [shuangSeQiu setType24:dict[@"type"]];
    [shuangSeQiu setType25:dict[@"type"]];
    [shuangSeQiu setType26:dict[@"type"]];
    [shuangSeQiu setType27:dict[@"type"]];
    [shuangSeQiu setType28:dict[@"type"]];
    [shuangSeQiu setType29:dict[@"type"]];
    [shuangSeQiu setType30:dict[@"type"]];
    [shuangSeQiu setType31:dict[@"type"]];
    [shuangSeQiu setType32:dict[@"type"]];
    
}
@end
